<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        /*

        function fun() {
            console.log(this.name);
        }

        // fun();

        //创建一个对象
        var obj = {
            name: "孙悟空",
            sayName: fun
        }

        var obj2 = {
            name: "沙和尚",
            sayName: fun
        }

        // console.log(obj.sayName == fun);
        var name = "全局的name属性"

        // obj2.sayName();

        //以函数形式调用，this就是window
        fun();

        */



        //创建一个name变量
        var name = "全局";

        //创建一个fun()函数
        function fun(){
            console.log(this.name);
        }

        //创建两个对象
        var obj = {
            name: "孙悟空",
            sayName: fun
        }

        var obj2 = {
            name: "沙和尚",
            sayName: fun
        }

        fun(); 




    </script>
</head>

<body>

</body>

</html>